package com.grantha.util;

import org.apache.log4j.Logger;

import com.grantha.bean.Patron;

public class Validator {
	private static Logger log = Logger.getLogger(Validator.class);
	public boolean validate(Patron p) {

		if (p.getName() == null && p.getName().equals(""))
			return false;
		else if (p.getSex() == null && p.getSex().equals(""))
			return false;
		else if (p.getAddress() == null && p.getAddress().equals(""))
			return false;
		else if (p.getPhone() == null && p.getPhone().equals(""))
			return false;
		else if (p.getGuranterName() == null && p.getGuranterName().equals(""))
			return false;
		else if (p.getGuranterPhone() == null
				&& p.getGuranterPhone().equals(""))
			return false;
		else if (p.getGuranterAddress() == null
				&& p.getGuranterAddress().equals(""))
			return false;
		else
			return true;

	}
    public static boolean checkBarcodeRange(String start, String end){
        if (!start.trim().equals("")&!end.trim().equals("")) {
            try {
                if (Integer.parseInt(start)>Integer.parseInt(end)) { 
                    return false;
                }else{
                    return true;
                }
            } catch (NumberFormatException e) {
            	log.error("Error start="+start+" end="+end);
            }
        }
		return false;

    }
}
